Skip to content

feat(cli): Add ui5 cache clean command - #1455

Open
d3xter666 wants to merge 33 commits into
mainfrom
feat/clean-cache-command
Open

feat(cli): Add ui5 cache clean command#1455
d3xter666 wants to merge 33 commits into
mainfrom
feat/clean-cache-command

Conversation

@d3xter666

@d3xter666 d3xter666 commented Jul 17, 2026

Copy link
Copy Markdown
Member

This PR introduces a new cache cleanup workflow for UI5 CLI via the ui5 cache clean command, including safer cleanup semantics, clearer user output, and recovery of leftovers from interrupted cleanup runs.

Why
Current cache cleanup requires manual directory deletion, which is error-prone and not ideal for CI or scripted usage.
This change provides a first-class command that:

Explains what will be removed before execution.
Supports non-interactive execution.
Handles stale cache artifacts from interrupted previous runs.

JIRA: CPOUI5FOUNDATION-891

@d3xter666
d3xter666 requested a review from a team July 17, 2026 06:34
@d3xter666
d3xter666 marked this pull request as draft July 17, 2026 06:34
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from 2195d0e to 979a629 Compare July 20, 2026 07:13
@d3xter666
d3xter666 changed the base branch from main to refactor/resolve-ui5-data-dir July 20, 2026 07:14
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from 979a629 to cc367f3 Compare July 20, 2026 12:22
d3xter666 added 10 commits July 21, 2026 16:26
Adds `ui5 cache clean` to remove framework packages and build cache data.
Displays what will be removed with library/version stats, asks for
confirmation (skip with --yes), and handles orphaned staging dirs from
previously interrupted cleans.

No process-coordination locks — that will be added separately.
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from f332519 to 89e915f Compare July 21, 2026 13:34
@d3xter666
d3xter666 changed the base branch from refactor/resolve-ui5-data-dir to main July 21, 2026 13:35
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from 28454d6 to a0444d5 Compare July 22, 2026 07:03
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from e35f673 to af2b848 Compare July 22, 2026 09:23
@d3xter666
d3xter666 marked this pull request as ready for review July 22, 2026 11:20
@d3xter666
d3xter666 removed the request for review from a team July 22, 2026 11:20
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from 3ead788 to db2912e Compare July 22, 2026 11:31
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from db2912e to c4e20b3 Compare July 22, 2026 11:32
@d3xter666
d3xter666 marked this pull request as draft July 22, 2026 11:41
For tables big enough, it could take a lot of time to run the VACUUM.
For that reason, do the same as the directory rename- rename tables
and later clean them up. This will not corrupt Db data and
will be able to resume if the process is killed
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from cc944d7 to 5c27a35 Compare July 23, 2026 06:24
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from 5c27a35 to bcaa7fa Compare July 23, 2026 06:29
@d3xter666
d3xter666 marked this pull request as ready for review July 23, 2026 06:57
@d3xter666
d3xter666 requested a review from a team July 23, 2026 07:00
Comment thread internal/documentation/docs/pages/Troubleshooting.md
@d3xter666
d3xter666 force-pushed the feat/clean-cache-command branch from 301caa6 to 0e631fa Compare July 23, 2026 12:35
@matz3

matz3 commented Jul 27, 2026

Copy link
Copy Markdown
Member

Note: When I run npm i with npm v11.18.0 I get a diff in the package-lock.json, adding yeso to the @ui5/cli deps.
Looks like the lockfile is not up to date?

}

/**
* Comma separated list of components to which orphaned resources should be added.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should rename this term here. The class has a createOrphanFilters, so I would propose that we do not change this.

* @returns {number} Database size in bytes before the drop (pending reclamation after vacuum)
*/
dropAllRecords() {
const tables = ["content", "index_cache", "stage_metadata", "task_metadata", "result_metadata"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same array values as above, so they need to stay in sync. Why not extracting this into a constant for all table names? Maybe we need it also somewhere else in future.

Comment on lines +596 to +597
this.#db.exec("VACUUM");
this.#db.exec("UPDATE _vacuum_pending SET pending = 0 WHERE rowid = 1");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also be an transaction?

* @param {string} ui5DataDir Resolved absolute path to UI5 data directory
* @returns {Promise<{path: string, size: number}|null>} Build cache info or null
*/
static async getCacheInfo(ui5DataDir) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the next three methods are almost identical, and it doesn't look like it would be too complex to refactor them into a common method that can be used for the individual ones, without creating more complexity.

* The directory is renamed to this prefix + a random hex suffix before deletion so that
* the original path is immediately removed and the deletion can proceed outside the rename.
*/
const STAGING_DIR_PREFIX = "_framework_to_delete_";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a different term than staging here as there is already a staging dir for downloading the framework libraries (.ui5/framework/staging), which can be confusing as they are fundamentally different. At least an addition, like "removal" or "delete" or something would help to identify that they are not the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants